﻿<BadHabit_WPFTools:ShapedWindow x:Class="BadHabit.Factory.Windows.TaskDetail"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Factory_Core="clr-namespace:BadHabit.Factory;assembly=FactoryCore"
    xmlns:BadHabit_Factory_Controls="clr-namespace:BadHabit.Factory.Controls"
    xmlns:BadHabit_WPFTools="clr-namespace:BadHabit.WPFTools;assembly=BadHabit.WPFTools"        
    xmlns:Microsoft_Toolkit="http://schemas.microsoft.com/wpf/2008/toolkit"
                                
    xmlns:props="clr-namespace:BadHabit.Factory.Properties"                                              
                                
    WindowStartupLocation="CenterScreen"
                                
    Loaded="ShapedWindow_Loaded"
                                
    Width="750"
                                
    Height="520"
                                
    
                                
    Background="White"
    
    SnapsToDevicePixels="True"                                
    Topmost="False"
    ShowInTaskbar="True"
    Icon="/Images/WindowsIcons/Factory.ico"                                
    Style="{StaticResource NormalWindow}"   
    Title="{Binding TaskName}">
    
    <BadHabit_WPFTools:ShapedWindow.Resources>
        <ObjectDataProvider x:Key="ProjectMemberList" ObjectInstance="{x:Null}"  />
        <ObjectDataProvider x:Key="UnitList" ObjectInstance="{x:Null}"  />
    </BadHabit_WPFTools:ShapedWindow.Resources>
    
    <BadHabit_WPFTools:ShapedWindow.CommandBindings>
        <CommandBinding Command="ApplicationCommands.Save" CanExecute="Save_CanExecute" Executed="Save_Executed"/>
    </BadHabit_WPFTools:ShapedWindow.CommandBindings>
        
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        
        <Grid Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <ToolBar Grid.Column="0" HorizontalAlignment="Stretch">
                <Menu>
                    <MenuItem Header="{x:Static props:Resources.Add_Material}" Style="{StaticResource ToolBarMenuItem}">
                        <MenuItem Header="{x:Static props:Resources.Add_a_Link}" Click="AddLink_Click"/>
                        <MenuItem Header="{x:Static props:Resources.Add_a_File}" Click="AddFile_Click"/>
                        <MenuItem.Icon>
                            <Image Source="/Images/ToolBar/attach.png" Stretch="Uniform" Width="32" Height="32"/>
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Header="{x:Static props:Resources.Project_Folder}" Style="{StaticResource ToolBarMenuItem}" Click="ProjectFolder_Click">
                        <MenuItem.Icon>
                            <Image Source="/Images/ToolBar/folder.png" Stretch="Uniform" Width="32" Height="32"/>
                        </MenuItem.Icon>
                    </MenuItem>

                </Menu>

            </ToolBar>

            <Button x:Name="commitButton"
                    Grid.Column="1"
                    Margin="5,0,5,0"
                    Style="{StaticResource CommitButton}"
                    HorizontalAlignment="Right"
                    ToolTip="{x:Static props:Resources.Commit_Task_Changes}"
                    Command="ApplicationCommands.Save"  />


        </Grid>

        <TabControl Grid.Row="1" Margin="0,5,0,0">
            <TabItem Header="{x:Static props:Resources.Task}">
                <Grid x:Name="taskGrid" HorizontalAlignment="Stretch" Margin="3">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" MinWidth="500"/>
                    </Grid.ColumnDefinitions>




                    <Grid Grid.Row="1" Grid.Column="0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>

                        <TextBlock Grid.Column="0" Grid.Row="0" Style="{StaticResource Label}" Text="{x:Static props:Resources.Number}"/>
                        <TextBlock Grid.Column="2" Grid.Row="0" Style="{StaticResource Label}" Text="{x:Static props:Resources.Status}"/>
                        <TextBlock Grid.Column="0" Grid.Row="1" Style="{StaticResource Label}" Text="{x:Static props:Resources.Name}"/>
                        <TextBlock Grid.Column="0" Grid.Row="2" Style="{StaticResource Label}" Text="{x:Static props:Resources.Assignee}"/>
                        <TextBlock Grid.Column="2" Grid.Row="2" Style="{StaticResource Label}" Text="{x:Static props:Resources.Role}"/>
                        <TextBlock Grid.Column="0" Grid.Row="3" Style="{StaticResource Label}" Text="{x:Static props:Resources.Type}"/>


                        <TextBox Grid.Column="1" Grid.Row="0" Style="{StaticResource LabelInfo}" Text="{Binding TaskId, Mode=OneWay}" />


                        <BadHabit_WPFTools:ComboBox                                                                                                                        
                                        Grid.Column="3" Grid.Row="0"
                                        Style="{StaticResource FormComboBox}"
                                        MinWidth="24"
                                        HorizontalContentAlignment="Center" VerticalContentAlignment="Center"                                                                                                                        
                                        SelectedValue="{Binding Status, Converter={StaticResource EnumConverter}, ConverterParameter={x:Type Factory_Core:TaskStatus} }"   
                                        ItemsSource="{Binding Source={StaticResource TaskStatusList}}"
                                        ItemTemplate="{StaticResource TaskStatusTemplate}"
                                        SelectedItemTemplate="{StaticResource TaskStatusTemplate}"                                        
                                        />

                        <TextBox Grid.Column="1" Grid.ColumnSpan="3" Grid.Row="1"
                         Style="{StaticResource FormTextBox}"
                         MaxLength="100"
                         Text="{Binding TaskName}" HorizontalAlignment="Stretch" FontSize="{StaticResource NeedToSeeFontSize}"/>

                        <!-- ASSIGNNEE -->
                        <BadHabit_WPFTools:ComboBox
                                Grid.Column="1" Grid.Row="2"   
                                Style="{StaticResource TeamComboBox}"           
                                 Background="{StaticResource FormInputBackgroundBrush}"
                                BorderBrush="{StaticResource FormInputBorderBrush}"
                                Margin="2"
                                Foreground="Black"
                                
                    BadHabit_WPFTools:RoleChecker.RequiredEnableRole="SCRUM_MASTER"
                                ItemsSource="{Binding Source={StaticResource ProjectMemberList}}"/>

                        <!-- ROLE -->
                        <BadHabit_WPFTools:ComboBox
                                Grid.Column="3" Grid.ColumnSpan="2" Grid.Row="2"
                                IsReadOnly="{Binding ., Converter={StaticResource IsReadOnlyTaskConverter}}"
                                                                                                                        
                                HorizontalAlignment="Stretch"
                                Style="{StaticResource FormComboBox}"
                                                                                                         
                                ItemsSource="{Binding Source={StaticResource UnitList}}"
                                SelectedValue="{Binding UnitName}"
                                DisplayMemberPath="UnitDescription"
                                SelectedValuePath="UnitName"
                                TextSearch.TextPath="UnitDescription"/>

                        <BadHabit_WPFTools:ComboBox                                                                    
                        Grid.Column="1" Grid.Row="3"
                        IsReadOnly="{Binding ., Converter={StaticResource IsReadOnlyTaskConverter}}"                        
                        Style="{StaticResource FormComboBox}"
                       
                        MinWidth="24"
                        HorizontalContentAlignment="Center" VerticalContentAlignment="Center"                        
                        SelectedValue="{Binding TaskType, Converter={StaticResource EnumConverter}, ConverterParameter={x:Type Factory_Core:TaskTypes} }"   
                        ItemsSource="{Binding Source={StaticResource TaskTypeList}}"
                        ItemTemplate="{StaticResource TaskTypeTemplate}"
                        SelectedItemTemplate="{StaticResource TaskTypeTemplate}"/>

                        <CheckBox Grid.Column="4" Grid.Row="3" IsChecked="{Binding Payable}" Content="{x:Static props:Resources.Payable}" >
                            <CheckBox.Style>
                                <Style TargetType="CheckBox" BasedOn="{StaticResource {x:Type CheckBox}}">
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding ., Converter={StaticResource IsReadOnlyTaskConverter}}" Value="True">
                                            <Setter Property="CheckBox.IsEnabled" Value="False"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </CheckBox.Style>
                        </CheckBox>



                        <TextBlock Grid.Column="0" Grid.Row="4" Text="{x:Static props:Resources.Created_by}" Style="{StaticResource Label}"/>
                        <TextBox Grid.Column="1" Grid.Row="4" Text="{Binding TaskOwner}" Style="{StaticResource LabelInfo}"/>
                        <TextBlock Grid.Column="2" Grid.Row="4" Text="{x:Static props:Resources.Created_at}" Style="{StaticResource Label}"/>
                        <TextBox Grid.Column="3" Grid.Row="4" Text="{Binding CreateDate}" Style="{StaticResource LabelInfo}"/>

                    </Grid>


                    <GroupBox Grid.Row="2" Grid.Column="0" Header="{x:Static props:Resources.Effort}">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>



                            <TextBlock Grid.Column="0" Grid.Row="0" Text="{x:Static props:Resources.Plan}" Style="{StaticResource Label}" FontWeight="Bold"/>

                            <StackPanel Grid.Column="1" Grid.Row="0" Orientation="Horizontal">
                                <TextBox Text="{Binding PlannedEffort, StringFormat='{}{0:f1}'}" Style="{StaticResource FormTextBox}" FontSize="20" FontWeight="Bold" Width="60" TextAlignment="Right" MaxLength="3" />
                                <TextBlock Style="{StaticResource Label}" Text="{x:Static props:Resources.hours}"/>
                            </StackPanel>

                            <TextBlock  Grid.Column="3" Grid.Row="0" Text="{x:Static props:Resources.From}" Style="{StaticResource Label}"/>

                            <StackPanel Grid.Column="4" Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Right" >



                                <Microsoft_Toolkit:DatePicker
                               
                                VerticalAlignment="Center"
                                SelectedDate="{Binding PlannedStart}" HorizontalAlignment="Left" >
                                    <Microsoft_Toolkit:DatePicker.Style>
                                        <Style TargetType="Microsoft_Toolkit:DatePicker" BasedOn="{StaticResource {x:Type Microsoft_Toolkit:DatePicker}}">
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding ., Converter={StaticResource IsReadOnlyTaskConverter}}" Value="True">
                                                    <Setter Property="Microsoft_Toolkit:DatePicker.IsEnabled" Value="False"/>
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </Microsoft_Toolkit:DatePicker.Style>
                                </Microsoft_Toolkit:DatePicker>

                                <TextBlock Text="{x:Static props:Resources.to}" Style="{StaticResource Label}"/>

                                <Microsoft_Toolkit:DatePicker
                               
                                VerticalAlignment="Center"
                                SelectedDate="{Binding PlannedFinish}">
                                    <Microsoft_Toolkit:DatePicker.Style>
                                        <Style TargetType="Microsoft_Toolkit:DatePicker" BasedOn="{StaticResource {x:Type Microsoft_Toolkit:DatePicker}}">
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding ., Converter={StaticResource IsReadOnlyTaskConverter}}" Value="True">
                                                    <Setter Property="Microsoft_Toolkit:DatePicker.IsEnabled" Value="False"/>
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </Microsoft_Toolkit:DatePicker.Style>

                                </Microsoft_Toolkit:DatePicker>
                            </StackPanel>

                            <TextBlock Grid.Column="0" Grid.Row="1" Text="{x:Static props:Resources.Worked}" Style="{StaticResource Label}" FontWeight="Bold"/>

                            <StackPanel Grid.Column="1" Grid.Row="1" Orientation="Horizontal">
                                <TextBox Text="{Binding ActualEffort, StringFormat='{}{0:f1}'}" Style="{StaticResource FormTextBox}" FontSize="20" FontWeight="Bold"  Width="60" TextAlignment="Right" MaxLength="3" />
                                <TextBlock Style="{StaticResource Label}" Text="{x:Static props:Resources.hours}"/>
                            </StackPanel>


                            <TextBlock  Grid.Column="3" Grid.Row="1" Text="{x:Static props:Resources.From}" Style="{StaticResource Label}"/>

                            <StackPanel Grid.Column="4" Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right" >

                                <Microsoft_Toolkit:DatePicker                               
                                VerticalAlignment="Center"
                                SelectedDate="{Binding Start}" HorizontalAlignment="Left" >
                                    <Microsoft_Toolkit:DatePicker.Style>
                                        <Style TargetType="Microsoft_Toolkit:DatePicker" BasedOn="{StaticResource {x:Type Microsoft_Toolkit:DatePicker}}">
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding ., Converter={StaticResource IsReadOnlyTaskConverter}}" Value="True">
                                                    <Setter Property="Microsoft_Toolkit:DatePicker.IsEnabled" Value="False"/>
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </Microsoft_Toolkit:DatePicker.Style>
                                </Microsoft_Toolkit:DatePicker>

                                <TextBlock Text="{x:Static props:Resources.to}" Style="{StaticResource Label}"/>

                                <Microsoft_Toolkit:DatePicker                               
                                VerticalAlignment="Center"
                                SelectedDate="{Binding Finish}">
                                    <Microsoft_Toolkit:DatePicker.Style>
                                        <Style TargetType="Microsoft_Toolkit:DatePicker" BasedOn="{StaticResource {x:Type Microsoft_Toolkit:DatePicker}}">
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding ., Converter={StaticResource IsReadOnlyTaskConverter}}" Value="True">
                                                    <Setter Property="Microsoft_Toolkit:DatePicker.IsEnabled" Value="False"/>
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </Microsoft_Toolkit:DatePicker.Style>

                                </Microsoft_Toolkit:DatePicker>
                            </StackPanel>





                        </Grid>
                    </GroupBox>

                    <GroupBox Grid.Column="0" Grid.Row="3" Header="{x:Static props:Resources.More_Details}">
                        <TextBox
                    Grid.Column="1" Grid.ColumnSpan="3" Grid.Row="4"
                    Style="{StaticResource FormTextBox}"
                    Text="{Binding TaskDescription}"                    
                    AcceptsReturn="True"
                    TextWrapping="Wrap"
                    MaxLength="500"
                    FontSize="{StaticResource NeedToSeeFontSize}"
                    VerticalAlignment="Stretch"
                            
                    VerticalScrollBarVisibility="Auto"/>
                    </GroupBox>


                </Grid>
            </TabItem>
            <TabItem Header="{x:Static props:Resources.Artifacts_Materials}" x:Name="tailTabItem">
                <Border Style="{StaticResource RoundBorder}">
                    <BadHabit_Factory_Controls:ArtifactListBox
                    x:Name="artifactListBox"
                        TaskUId="{Binding TaskUId}"
                        AllowDrop="True"
                    Background="Transparent"
                    ScrollViewer.VerticalScrollBarVisibility="Auto"     
                    ScrollViewer.HorizontalScrollBarVisibility="Disabled"                        
                    HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
                </Border>
            </TabItem>
        </TabControl>




        <StatusBar Grid.Row="2">
            <TextBlock x:Name="projectNameTextBlock" Text="Project"/>
            <TextBlock x:Name="backlogItemNumberTextBlock" Text="{Binding BacklogItemNumber, StringFormat='{}, item {0}'}"/>
        </StatusBar>

    </Grid>

    
</BadHabit_WPFTools:ShapedWindow>
